<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<script>
    function getMost(str) {
        var result = {};
        for(let i in str) {
            if(str[i] in result) {
                result[str[i]]++;
            } else {
                var object = {};
                object[str[i]] = 1;
                result = Object.assign(result, object);
            }
        }
        return result;
    }

    var result = getMost("xyzzyxyz");
    console.log(result);

</script>
<body>

</body>
</html>